"""
自定义的pyautogui:自定义一些pyautogui的一些方法
"""
import pyautogui

class MyPyautogui():

    @pyautogui._genericPyAutoGUIChecks
    def drag_to(self, x=None, y=None, duration=0.0, tween=pyautogui.linear, button="primary", logScreenshot=None,
                _pause=True, mouseDown=True, mouseUp=True):
        """
        拖动方法：补充原来的dropTo会每次都释放鼠标
        """

        x, y = pyautogui._normalizeXYArgs(x, y)

        pyautogui._logScreenshot(logScreenshot, "dragTo", "%s,%s" % (x, y), folder=".")
        if mouseDown:
            pyautogui.mouseDown(button=button, logScreenshot=False, _pause=False)
        pyautogui._mouseMoveDrag("drag", x, y, 0, 0, duration, tween, button)
        if mouseUp:
            pyautogui.mouseUp(button=button, logScreenshot=False, _pause=False)